Source code for /engineering/webperf/slave-v4[j1.2]/CmdQueue.javaOriginal file CmdQueue.java
   1 import java.util.*;
   2 
   3 public class CmdQueue {
   4    
   5    ObjectMonitor   myLock; 
   6    Vector		 queue;  
   7    int 		 queueSize;
   8 
   9    CmdQueue() {
  10 	myLock    = new ObjectMonitor();
  11       queue     = new Vector();
  12       queueSize = 0;
  13    }
  14 
  15    public Command getCommand() {
  16       Command c = null;
  17       // blocks until a message arrives
  18       myLock.lock(true);
  19       if (!queue.isEmpty()) {
  20          c = (Command) queue.elementAt(0);         
  21          queue.removeElementAt(0);
  22 	   queueSize--;
  23       }
  24       myLock.lock(false);
  25       return c;
  26    }
  27    
  28    public void putCommand(Command c) {
  29       myLock.lock(true);
  30       queue.addElement(c);
  31 	queueSize++;
  32       myLock.lock(false);
  33    }
  34    
  35    public boolean isCommand() {
  36       if (queueSize > 0) return true;
  37 	else return false;
  38    }
  39         
  40 }